package com.bosssoft.springboot.demo4.job;

import com.bosssoft.springboot.demo4.service.EMailService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;
import java.util.Date;

@Slf4j
public class HelloEmailJob implements Job {

    @Autowired
    private EMailService eMailService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        Date date = new Date();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        log.info("现在的时间是{}",sf.format(date));
        log.info("开始发送邮件");
        eMailService.send("1329075259@qq.com","chen_tong_q@163.com","test","hello world");

    }
}
